```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java线程池创建方式详解 | 技术小馆</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6e8efb 0%, #4a6cf7 100%);
        }
        .code-block {
            background-color: #2d3748;
            border-radius: 0.5rem;
            color: #f7fafc;
            font-family: 'Courier New', Courier, monospace;
        }
        .section-card {
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }
        .section-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        }
        .mermaid svg {
            display: block;
            margin: 0 auto;
        }
        .highlight {
            position: relative;
        }
        .highlight::after {
            content: '';
            position: absolute;
            bottom: -2px;
            left: 0;
            width: 100%;
            height: 2px;
            background: linear-gradient(90deg, #4a6cf7, #6e8efb);
            transform: scaleX(0);
            transition: transform 0.3s ease;
            transform-origin: right;
        }
        .highlight:hover::after {
            transform: scaleX(1);
            transform-origin: left;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <header class="hero-gradient text-white py-20 md:py-32 px-4">
        <div class="max-w-6xl mx-auto text-center">
            <h1 class="text-4xl md:text-5xl font-bold mb-6 font-serif">Java线程池创建方式详解</h1>
            <p class="text-xl md:text-2xl max-w-3xl mx-auto opacity-90 mb-8">探索Java中多种线程池创建方式及其适用场景</p>
            <div class="flex justify-center space-x-4">
                <a href="#threadpoolexecutor" class="px-6 py-3 bg-white text-blue-600 font-medium rounded-full hover:bg-blue-50 transition-colors duration-300">
                    <i class="fas fa-code mr-2"></i>ThreadPoolExecutor
                </a>
                <a href="#executors" class="px-6 py-3 bg-white text-blue-600 font-medium rounded-full hover:bg-blue-50 transition-colors duration-300">
                    <i class="fas fa-industry mr-2"></i>Executors
                </a>
            </div>
        </div>
    </header>

    <!-- Main Content -->
    <main class="max-w-6xl mx-auto px-4 py-12">
        <!-- Introduction Section -->
        <section class="mb-16">
            <div class="bg-white rounded-xl shadow-md p-8 section-card">
                <h2 class="text-2xl font-bold mb-6 text-gray-800 font-serif">线程池创建方式概述</h2>
                <p class="mb-4 text-gray-700">在Java中，线程池可以通过<strong class="text-blue-600">ThreadPoolExecutor</strong>类直接创建，通过构造函数传入核心线程数、最大线程数、线程存活时间、任务队列等参数来自定义线程池，或者通过<strong class="text-blue-600">Executors</strong>工厂类提供的静态方法快速创建常见类型的线程池，例如固定大小线程池、缓存线程池、单线程线程池等。</p>
                
                <div class="mt-8">
                    <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1711768915874-2f82bf24-aa5f-42ef-af2a-e2bf668c1454.png" alt="Java线程池创建方式" class="rounded-lg shadow-md mx-auto">
                </div>
            </div>
        </section>

        <!-- ThreadPoolExecutor Section -->
        <section id="threadpoolexecutor" class="mb-16">
            <div class="bg-white rounded-xl shadow-md p-8 section-card">
                <div class="flex items-center mb-6">
                    <div class="bg-blue-100 w-12 h-12 rounded-full flex items-center justify-center mr-4">
                        <i class="fas fa-code text-blue-600 text-xl"></i>
                    </div>
                    <h2 class="text-2xl font-bold text-gray-800 font-serif">使用ThreadPoolExecutor类</h2>
                </div>
                
                <p class="mb-6 text-gray-700">在Java中，可以使用<strong class="text-blue-600">ThreadPoolExecutor</strong>类来创建线程池，通过构造函数传入参数来自定义线程池的属性，包括核心线程数、最大线程数、线程存活时间、任务队列等。</p>
                
                <div class="mt-6 mb-8">
                    <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1711768954515-c46b3f88-8388-4b3a-92f7-6464723ce1e1.png" alt="ThreadPoolExecutor创建方式" class="rounded-lg shadow-md mx-auto">
                </div>
                
                <div class="grid md:grid-cols-2 gap-8">
                    <div>
                        <h3 class="text-xl font-semibold mb-4 text-gray-800 font-serif">1. 创建ThreadPoolExecutor实例</h3>
                        <pre class="code-block p-4 overflow-x-auto"><code class="language-java">int corePoolSize = 5; // 核心线程数
int maxPoolSize = 10; // 最大线程数
long keepAliveTime = 60; // 线程空闲时间
TimeUnit unit = TimeUnit.SECONDS; // 时间单位
BlockingQueue&lt;Runnable&gt; workQueue = 
    new LinkedBlockingQueue&lt;&gt;(); // 任务队列

ThreadPoolExecutor executor = new ThreadPoolExecutor(
    corePoolSize, 
    maxPoolSize, 
    keepAliveTime, 
    unit, 
    workQueue
);</code></pre>
                        <p class="mt-4 text-gray-700">通过这种方式创建的线程池可以灵活地配置线程池的属性，例如核心线程数、最大线程数、线程空闲时间等，以及选择合适的任务队列类型来管理任务的排队和调度。</p>
                    </div>
                    
                    <div>
                        <h3 class="text-xl font-semibold mb-4 text-gray-800 font-serif">2. 提交任务给线程池执行</h3>
                        <pre class="code-block p-4 overflow-x-auto"><code class="language-java">executor.execute(new Runnable() {
    @Override
    public void run() {
        // 执行任务的逻辑
    }
});</code></pre>
                        <p class="mt-4 text-gray-700">通过调用线程池的<strong class="text-blue-600">execute()</strong>方法提交任务给线程池执行，线程池会根据自身的配置来管理线程的执行和任务的调度。</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Executors Section -->
        <section id="executors" class="mb-16">
            <div class="bg-white rounded-xl shadow-md p-8 section-card">
                <div class="flex items-center mb-6">
                    <div class="bg-blue-100 w-12 h-12 rounded-full flex items-center justify-center mr-4">
                        <i class="fas fa-industry text-blue-600 text-xl"></i>
                    </div>
                    <h2 class="text-2xl font-bold text-gray-800 font-serif">使用Executors工厂类</h2>
                </div>
                
                <p class="mb-6 text-gray-700">也可以使用<strong class="text-blue-600">Executors</strong>工厂类来创建线程池，<strong class="text-blue-600">Executors</strong>提供了一些静态工厂方法来创建不同类型的线程池，例如固定大小线程池、缓存线程池、单线程线程池等。</p>
                
                <div class="mt-6 mb-8">
                    <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1711768988080-b9d25aee-7326-473f-b066-98c504681bcf.png" alt="Executors创建方式" class="rounded-lg shadow-md mx-auto">
                </div>
                
                <div class="grid md:grid-cols-2 gap-8">
                    <div>
                        <h3 class="text-xl font-semibold mb-4 text-gray-800 font-serif">1. 创建固定大小线程池</h3>
                        <pre class="code-block p-4 overflow-x-auto"><code class="language-java">int nThreads = 5; // 线程池大小
ExecutorService executor = 
    Executors.newFixedThreadPool(nThreads);</code></pre>
                        <p class="mt-4 text-gray-700">通过<strong class="text-blue-600">Executors.newFixedThreadPool(nThreads)</strong>方法可以创建一个固定大小的线程池，该线程池包含固定数量的线程，当有新的任务提交时，线程池中的线程将会复用，直到线程池关闭。</p>
                    </div>
                    
                    <div>
                        <h3 class="text-xl font-semibold mb-4 text-gray-800 font-serif">2. 提交任务给线程池执行</h3>
                        <pre class="code-block p-4 overflow-x-auto"><code class="language-java">executor.execute(new Runnable() {
    @Override
    public void run() {
        // 执行任务的逻辑
    }
});</code></pre>
                        <p class="mt-4 text-gray-700">使用<strong class="text-blue-600">Executors</strong>工厂类创建线程池简单方便，但是在某些场景下可能不够灵活，例如不能直接设置核心线程数、最大线程数和线程空闲时间等属性，也不能选择合适的拒绝策略来处理任务队列满的情况。因此，在实际项目中需要根据具体需求来选择合适的线程池创建方式。</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Custom Thread Pool Section -->
        <section class="mb-16">
            <div class="bg-white rounded-xl shadow-md p-8 section-card">
                <div class="flex items-center mb-6">
                    <div class="bg-blue-100 w-12 h-12 rounded-full flex items-center justify-center mr-4">
                        <i class="fas fa-cogs text-blue-600 text-xl"></i>
                    </div>
                    <h2 class="text-2xl font-bold text-gray-800 font-serif">自定义线程池</h2>
                </div>
                
                <p class="mb-6 text-gray-700">在Java中，除了使用<code>ThreadPoolExecutor</code>类和<code>Executors</code>工厂类创建线程池外，还可以通过自定义线程池来实现更灵活的线程池配置。自定义线程池可以满足特定需求，例如设置特定的线程池参数、自定义任务队列、自定义线程工厂等。</p>
                
                <div class="grid md:grid-cols-2 gap-8">
                    <div>
                        <h3 class="text-xl font-semibold mb-4 text-gray-800 font-serif">1. 创建自定义线程池类</h3>
                        <pre class="code-block p-4 overflow-x-auto"><code class="language-java">import java.util.concurrent.*;

public class CustomThreadPool {
    private ThreadPoolExecutor executor;

    public CustomThreadPool(int corePoolSize, 
                          int maxPoolSize, 
                          long keepAliveTime, 
                          BlockingQueue&lt;Runnable&gt; workQueue) {
        executor = new ThreadPoolExecutor(
            corePoolSize, 
            maxPoolSize, 
            keepAliveTime, 
            TimeUnit.SECONDS, 
            workQueue
        );
    }

    public void executeTask(Runnable task) {
        executor.execute(task);
    }

    public void shutdown() {
        executor.shutdown();
    }
}</code></pre>
                        <p class="mt-4 text-gray-700">在自定义线程池类中，我们使用<code>ThreadPoolExecutor</code>类来创建线程池，并提供了方法来执行任务和关闭线程池。</p>
                    </div>
                    
                    <div>
                        <h3 class="text-xl font-semibold mb-4 text-gray-800 font-serif">2. 使用自定义线程池</h3>
                        <pre class="code-block p-4 overflow-x-auto"><code class="language-java">public class Main {
    public static void main(String[] args) {
        int corePoolSize = 5; // 核心线程数
        int maxPoolSize = 10; // 最大线程数
        long keepAliveTime = 60; // 线程空闲时间
        BlockingQueue&lt;Runnable&gt; workQueue = 
            new LinkedBlockingQueue&lt;&gt;(); // 任务队列

        CustomThreadPool customThreadPool = new CustomThreadPool(
            corePoolSize, 
            maxPoolSize, 
            keepAliveTime, 
            workQueue
        );

        // 提交任务给线程池执行
        for (int i = 0; i < 10; i++) {
            customThreadPool.executeTask(new Task(i));
        }

        // 关闭线程池
        customThreadPool.shutdown();
    }
}

class Task implements Runnable {
    private int taskId;

    public Task(int taskId) {
        this.taskId = taskId;
    }

    @Override
    public void run() {
        System.out.println("Task " + taskId + " is running.");
    }
}</code></pre>
                        <p class="mt-4 text-gray-700">在主程序中，我们通过自定义线程池类创建了一个自定义的线程池，并提交了10个任务给线程池执行。每个任务执行的逻辑在<code>Task</code>类中实现。最后调用<code>shutdown()</code>方法关闭线程池。使用自定义线程池创建方式可以灵活地配置线程池的属性，并提供自定义的线程池管理和调度策略，适用于更复杂的场景和需求。</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Spring Thread Pool Section -->
        <section class="mb-16">
            <div class="bg-white rounded-xl shadow-md p-8 section-card">
                <div class="flex items-center mb-6">
                    <div class="bg-blue-100 w-12 h-12 rounded-full flex items-center justify-center mr-4">
                        <i class="fas fa-leaf text-blue-600 text-xl"></i>
                    </div>
                    <h2 class="text-2xl font-bold text-gray-800 font-serif">Spring框架中的线程池</h2>
                </div>
                
                <p class="mb-6 text-gray-700">在Spring框架中，可以使用<strong class="text-blue-600">TaskExecutor</strong>接口和<strong class="text-blue-600">ThreadPoolTaskExecutor</strong>类来创建线程池。<strong class="text-blue-600">ThreadPoolTaskExecutor</strong>是<strong class="text-blue-600">TaskExecutor</strong>接口的实现类，提供了更丰富的线程池配置选项。</p>
                
                <div class="mt-6 mb-8">
                    <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1711769078268-231ab573-d9ca-46f3-b0f7-968e9100dcf9.png" alt="Spring线程池" class="rounded-lg shadow-md mx-auto">
                </div>
                
                <div class="grid md:grid-cols-2 gap-8">
                    <div>
                        <h3 class="text-xl font-semibold mb-4 text-gray-800 font-serif">1. 创建配置类定义线程池bean</h3>
                        <pre class="code-block p-4 overflow-x-auto"><code class="language-java">import org.springframework.context.annotation.*;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

@Configuration
@EnableAsync
public class ThreadPoolConfig {

    @Bean
    public ThreadPoolTaskExecutor taskExecutor() {
        ThreadPoolTaskExecutor executor = 
            new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(5);
        executor.setMaxPoolSize(10);
        executor.setQueueCapacity(100);
        executor.setThreadNamePrefix("MyThread-");
        executor.initialize();
        return executor;
    }
}</code></pre>
                        <p class="mt-4 text-gray-700">在配置类中使用<code>@Configuration</code>注解标记为配置类，并使用<code>@EnableAsync</code>注解启用异步支持。通过<code>@Bean</code>注解定义<code>ThreadPoolTaskExecutor</code>类型的bean，配置线程池的属性。</p>
                    </div>
                    
                    <div>
                        <h3 class="text-xl font-semibold mb-4 text-gray-800 font-serif">2. 创建异步方法</h3>
                        <pre class="code-block p-4 overflow-x-auto"><code class="language-java">import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Service
public class AsyncService {

    @Async
    public void executeAsyncTask(int taskId) {
        System.out.println("Task " + taskId + 
            " is running on thread " + 
            Thread.currentThread().getName());
    }
}</code></pre>
                        <p class="mt-4 text-gray-700">在该服务类中定义一个异步方法，使用<code>@Async</code>注解标记为异步方法。</p>
                        
                        <h3 class="text-xl font-semibold mt-6 mb-4 text-gray-800 font-serif">3. 调用异步方法</h3>
                        <pre class="code-block p-4 overflow-x-auto"><code class="language-java">import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

@Component
public class AppRunner implements CommandLineRunner {

    @Autowired
    private AsyncService asyncService;

    @Override
    public void run(String... args) throws Exception {
        // 提交任务给线程池执行
        for (int i = 0; i < 10; i++) {
            asyncService.executeAsyncTask(i);
        }
    }
}</code></pre>
                        <p class="mt-4 text-gray-700">在应用启动类或其他启动任务时调用异步服务类中的异步方法，任务将被提交给线程池执行。</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Concurrent Thread Pool Section -->
        <section class="mb-16">
            <div class="bg-white rounded-xl shadow-md p-8 section-card">
                <div class="flex items-center mb-6">
                    <div class="bg-blue-100 w-12 h-12 rounded-full flex items-center justify-center mr-4">
                        <i class="fas fa-project-diagram text-blue-600 text-xl"></i>
                    </div>
                    <h2 class="text-2xl font-bold text-gray-800 font-serif">并发包中的线程池</h2>
                </div>
                
                <p class="mb-6 text-gray-700">Java并发包中提供了一些线程池的实现，例如ForkJoinPool、ScheduledThreadPoolExecutor等，它们适用于特定的场景或者特定类型的任务。</p>
                
                <div class="space-y-8">
                    <div class="bg-gray-50 p-6 rounded-lg">
                        <h3 class="text-xl font-semibold mb-4 text-gray-800 font-serif">1. FixedThreadPool</h3>
                        <p class="mb-4 text-gray-700"><code>FixedThreadPool</code>是固定大小的线程池实现，核心线程数和最大线程数都是固定的。适用于执行长期任务的场景，可以避免线程数量过多导致资源浪费。</p>
                        <pre class="code-block p-4 overflow-x-auto"><code class="language-java">import java.util.concurrent.*;

public class FixedThreadPoolExample {
    public static void main(String[] args) {
        ExecutorService executor = 
            Executors.newFixedThreadPool(3);

        // 提交任务给线程池执行
        for (int i = 0; i < 10; i++) {
            int taskNum = i;
            executor.execute(() -> {
                System.out.println("Task " + taskNum + 
                    " is running on thread " + 
                    Thread.currentThread().getName());
            });
        }

        // 关闭线程池
        executor.shutdown();
    }
}</code></pre>
                    </div>
                    
                    <div class="bg-gray-50 p-6 rounded-lg">
                        <h3 class="text-xl font-semibold mb-4 text-gray-800 font-serif">2. CachedThreadPool</h3>
                        <p class="mb-4 text-gray-700"><code>CachedThreadPool</code>是大小可变的线程池实现，可以根据需要动态地创建新线程，没有固定的核心线程数，最大线程数为<code>Integer.MAX_VALUE</code>。适用于执行短期异步任务的场景，线程池的大小会根据任务的数量动态调整。</p>
                        <pre class="code-block p-4 overflow-x-auto"><code class="language-java">import java.util.concurrent.*;

public class CachedThreadPoolExample {
    public static void main(String[] args) {
        ExecutorService executor = 
            Executors.newCachedThreadPool();

        // 提交任务给线程池执行
        for (int i = 0; i < 10; i++) {
            int taskNum = i;
            executor.execute(() -> {
                System.out.println("Task " + taskNum + 
                    " is running on thread " + 
                    Thread.currentThread().getName());
            });
        }

        // 关闭线程池
        executor.shutdown();
    }
}</code></pre>
                    </div>
                    
                    <div class="bg-gray-50 p-6 rounded-lg">
                        <h3 class="text-xl font-semibold mb-4 text-gray-800 font-serif">3. ScheduledThreadPoolExecutor</h3>
                        <p class="mb-4 text-gray-700"><code>ScheduledThreadPoolExecutor</code>是具有定时执行功能的线程池实现，可以在给定的延迟时间或固定的时间间隔后执行任务。适用于需要定时执行任务或周期性执行任务的场景。</p>
                        <pre class="code-block p-4 overflow-x-auto"><code class="language-java">import java.util.concurrent.*;

public class ScheduledThreadPoolExecutorExample {
    public static void main(String[] args) {
        ScheduledExecutorService executor = 
            Executors.newScheduledThreadPool(2);

        // 延迟1秒后执行任务
        ScheduledFuture&lt;?&gt; future1 = executor.schedule(() -> {
            System.out.println("Task 1 is running on thread " + 
                Thread.currentThread().getName());
        }, 1, TimeUnit.SECONDS);

        // 延迟2秒后执行任务，并每隔3秒执行一次
        ScheduledFuture&lt;?&gt; future2 = executor.scheduleAtFixedRate(() -> {
            System.out.println("Task 2 is running on thread " + 
                Thread.currentThread().getName());
        }, 2, 3, TimeUnit.SECONDS);

        // 延迟3秒后执行任务，并每隔4秒执行一次
        ScheduledFuture&lt;?&gt; future3 = executor.scheduleWithFixedDelay(() -> {
            System.out.println("Task 3 is running on thread " + 
                Thread.currentThread().getName());
        }, 3, 4, TimeUnit.SECONDS);

        // 等待任务执行完成
        try {
            future1.get();
            future2.get();
            future3.get();
        } catch (InterruptedException | ExecutionException e) {
            e.printStackTrace();
        }

        // 关闭线程池
        executor.shutdown();
    }
}</code></pre>
                    </div>
                    
                    <div class="bg-gray-50 p-6 rounded-lg">
                        <h3 class="text-xl font-semibold mb-4 text-gray-800 font-serif">4. ForkJoinPool</h3>
                        <p class="mb-4 text-gray-700"><code>ForkJoinPool</code>是一种特殊的线程池实现，适用于分治任务的并行处理。它将任务分解为更小的子任务，并通过工作窃取（work stealing）算法将子任务分配给空闲的工作线程，以实现更好的并行性能。</p>
                        <pre class="code-block p-4 overflow-x-auto"><code class="language-java">import java.util.concurrent.*;

public class ForkJoinPoolExample {
    public static void main(String[] args) {
        ForkJoinPool pool = new ForkJoinPool();

        // 提交任务给线程池执行
        pool.submit(() -> {
            System.out.println("Task is running on thread " + 
                Thread.currentThread().getName());
        });

        // 关闭线程池
        pool.shutdown();
    }
}</code></pre>
                        <p class="mt-4 text-gray-700">每种线程池实现都具有不同的特点和适用场景，开发者可以根据具体的需求选择合适的线程池实现来优化应用的性能和资源利用率。</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Visualization Section -->
        <section class="mb-16">
            <div class="bg-white rounded-xl shadow-md p-8 section-card">
                <div class="flex items-center mb-6">
                    <div class="bg-blue-100 w-12 h-12 rounded-full flex items-center justify-center mr-4">
                        <i class="fas fa-chart-network text-blue-600 text-xl"></i>
                    </div>
                    <h2 class="text-2xl font-bold text-gray-800 font-serif">线程池类型对比</h2>
                </div>
                
                <div class="mermaid">
                    graph TD
                    A[Java线程池] --> B[ThreadPoolExecutor]
                    A --> C[Executors工厂类]
                    A --> D[自定义线程池]
                    A --> E[Spring ThreadPoolTaskExecutor]
                    A --> F[并发包线程池]
                    
                    B --> B1[核心线程数]
                    B --> B2[最大线程数]
                    B --> B3[线程存活时间]
                    B --> B4[任务队列]
                    
                    C --> C1[newFixedThreadPool]
                    C --> C2[newCachedThreadPool]
                    C --> C3[newSingleThreadExecutor]
                    C --> C4[newScheduledThreadPool]
                    
                    D --> D1[灵活配置]
                    D --> D2[自定义策略]
                    D --> D3[特殊需求]
                    
                    E --> E1[Spring集成]
                    E --> E2[异步支持]
                    E --> E3[@Async注解]
                    
                    F --> F1[ForkJoinPool]
                    F --> F2[ScheduledThreadPoolExecutor]
                    F --> F3[WorkStealingPool]
                </div>
                
                <div class="mt-8 grid md:grid-cols-2 gap-6">
                    <div class="bg-blue-50 p-6 rounded-lg">
                        <h3 class="text-xl font-semibold mb-4 text-gray-800 font-serif">何时选择ThreadPoolExecutor</h3>
                        <ul class="space-y-2 text-gray-700">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-blue-500 mr-2 mt-1"></i>
                                <span>需要精确控制线程池参数</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-blue-500 mr-2 mt-1"></i>
                                <span>需要自定义拒绝策略</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-blue-500 mr-2 mt-1"></i>
                                <span>需要特定的任务队列实现</span>
                            </li>
                        </ul>
                    </div>
                    
                    <div class="bg-green-50 p-6 rounded-lg">
                        <h3 class="text-xl font-semibold mb-4 text-gray-800 font-serif">何时选择Executors工厂类</h3>
                        <ul class="space-y-2 text-gray-700">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>
                                <span>快速创建标准配置的线程池</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>
                                <span>简单应用场景</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>
                                <span>不需要精细控制线程池参数</span>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-12 px-4">
        <div class="max-w-6xl mx-auto">
            <div class="flex flex-col items-center">
                <h3 class="text-xl font-bold mb-2">技术小馆</h3>
                <a href="http://www.yuque.com/jtostring" class="text-gray-400 hover:text-white transition-colors duration-300">
                    <i class="fas fa-globe mr-2"></i>http://www.yuque.com/jtostring
                </a>
                <div class="mt-6 flex space-x-4">
                    <a href="#" class="text-gray-400 hover:text-white transition-colors duration-300">
                        <i class="fab fa-github text-xl"></i>
                    </a>
                    <a href="#" class="text-gray-400 hover:text-white transition-colors duration-300">
                        <i class="fab fa-twitter text-xl"></i>
                    </a>
                    <a href="#" class="text-gray-400 hover:text-white transition-colors duration-300">
                        <i class="fab fa-linkedin text-xl"></i>
                    </a>
                </div>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```